<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    
	
	<title>_订单信息查询</title>
	<script type="text/javascript">
	
        $(function() {
		    $("#queryForm").validate(); 
		    $("#inputForm").validate(); //为inputForm注册validate函数
			$("#_fromDate").datepicker({ format : 'yyyy-mm-dd' });
			$("#_toDate").datepicker({ format : 'yyyy-mm-dd' });
       });
	  
	  
	  function query(){
		  var batchCode=$("#_batchCode").val().trim();
		  var taskCode=$("#_taskCode").val().trim();
		  var orderno=$("#_orderno").val().trim();
		  var expressNo=$("#_expressNo").val().trim();
		  
		  if(batchCode=='' && taskCode=='' && orderno=='' && expressNo=='' ){
			  alert("至少输入一个编码查询条件...");
			  return;
		  }else{
			  $("#queryForm").submit();
		  }
	  }
	  
	  function  ajaxCreateMailOrdeno(item){
		  $("#mail_"+item).attr("disabled",true);
		  $.ajax({
				type : 'post',
				url : '${ctx}/orderMsg/v2_ajaxCreateMailOrdeno',
				data : 'id=' + item,
				dataType : 'json',
				success : function(data) {
				   alert(data.content);
				},
				error : function() {
					alert("获取信息错误！");
				}
			});
	  }
	  
	  function  ajaxSendOutOrdeno(item){
		  $("#send_"+item).attr("disabled",true);
		  $.ajax({
				type : 'post',
				url : '${ctx}/orderMsg/ajaxSendOutOrdeno',
				data : 'id=' + item,
				dataType : 'json',
				success : function(data) {
				   alert(data.content);
				},
				error : function() {
					alert("获取信息错误！");
				}
			});
	  }
	  
	  function  ajaxRouteInfo(item){
		  $("#send_"+item).attr("disabled",true);
		  $.ajax({
				type : 'post',
				url : '${ctx}/orderMsg/ajaxRouteInfo',
				data : 'id=' + item,
				dataType : 'json',
				success : function(data) {
				   alert(data.content);
				},
				error : function() {
					alert("获取信息错误！");
				}
			});
	  }
	  // 虚拟关联运单纯测试逻辑
	  function  ajaxKuaidiSimulatorTest(item){
		  $("#simulator_"+item).attr("disabled",true);
		  $.ajax({
				type : 'post',
				url : '${ctx}/orderMsg/ajaxKuaidiSimulatorTest',
				data : 'id=' + item,
				dataType : 'json',
				success : function(data) {
				   alert(data.content);
				   $("#simulator_"+item).attr("disabled",false);
				},
				error : function() {
					alert("获取信息错误！");
					$("#simulator_"+item).attr("disabled",false);
				}
			});
	  }
	  
    </script>
</head>

<body>
<section class="content">
    <!-- 查询条件  start-->
<div class="row">
	<div class="col-md-12">
			<!-- Primary box -->
			<div class="box box-solid box-primary" >
				<div class="box-header">
					<i class="fa fa-search"></i>
					<h3 class="box-title">搜索栏</h3>
				</div>
				<div class="box-body">	
					<form class="form-search" id="queryForm" action="${ctx}/orderMsg/v2_queryOrderMsg" method="post">
					<div class="form-group row">
						<div class="col-sm-3">
							<div class="input-textgroup col-sm-12">
							    <span class="input-group-text">商家名称:</span>
								 <select class="form-control"  name="_customerCode"  id="_customerCode" value="${param._customerCode}" onchange="ajaxAreaGroup(this,'_warehouseCode');">
									<option value=""></option>
									<c:forEach items="${customerList}" var="customer">
										<option value="${customer.customerCode}"
										<c:if test="${param._customerCode eq customer.customerCode}">selected=selected</c:if>
										>${customer.customerName}</option>
									</c:forEach>
								</select>
							</div>
						</div>
						
						<div class="col-sm-3">
							<div class="input-textgroup col-sm-12">
								<span class="input-group-text">作业仓库:</span>
								<select class="form-control"   name="_warehouseCode"  id="_warehouseCode" value="${param._warehouseCode}" >
									<option value=""></option>
									<c:forEach items="${warehouseList}" var="wm">
										<option value="${wm.groupCode}"
										<c:if test="${param._warehouseCode eq wm.groupCode}">selected=selected</c:if>
										>${wm.groupName}</option>
									</c:forEach>
								</select>
							</div>
						</div>
						<div class="col-sm-3">
							<div class="input-textgroup col-sm-12">
								<span class="input-group-text">作业批次号:</span>
								<input type="text" class="form-control" id="_batchCode" name="_batchCode" value="${param._batchCode}" onchange="query();"/>
							</div>
						</div>
						<div class="col-sm-3">
							<div class="input-textgroup col-sm-12">
								<span class="input-group-text">作业任务号:</span>
								<input type="text" class="form-control	" id="_taskCode" name="_taskCode" value="${param._taskCode}" onchange="query();"/>
							</div>
						</div>
			 	</div>
			    <div class="form-group row">
						<div class="col-sm-3">
							<div class="input-textgroup col-sm-12">
					            <span class="input-group-text">订单编号:</span>
								<input type="text" class="form-control	" id="_orderno" name="_orderno" value="${param._orderno}" onchange="query();"/>
							</div>
						</div>
						<div class="col-sm-3">
							<div class="input-textgroup col-sm-12">
								<span class="input-group-text">快递单号:</span>
								<input type="text" class="form-control	" id="_expressNo" name="_expressNo" value="${param._expressNo}" onchange="query();"/>
							</div>
						</div>				
						<div class="col-sm-3">
							<div class="input-textgroup col-sm-12">
								<button type="button" class="btn btn-info" style="margin-left: 10px;" onclick="query();">搜索</button>
							</div>
						</div>
				</div>
	    
	      </form>
		</div>
	   </div>
	  </div>
	</div>
	
 <div class="form-group row">
		<div class="col-md-12">
			<div class="box box-solid box-primary">
				<div class="box-header">
					<i class="fa fa-list"></i>
					<h3 class="box-title">查询结果</h3>
					<div class="box-tools pull-right">
						<button class="btn btn-primary btn-sm" data-widget="collapse" type="button">
							<i class="fa fa-minus"></i>
						</button>
					</div>
				</div>
	<div class="box-body">
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead><tr>
			    <th>序号</th>
			    <th>商家</th>
			    <th>能容订单号</th>
			    <th>商家订单号</th>
			    <th>来源订单号</th>
			    <th>快递单号</th>
			    <th>运单类型</th>
			    <th>仓库</th>
			    <th>批次</th>
			    <th>任务</th>
			    <th>状态</th>
			    <th>操作</th>
			</tr></thead>
		<tbody>
		<c:forEach items="${orderList}" var="o" varStatus="i">
			<tr>
			   <td>${i.count}</td>
			   <td>${o.customer.customerName}</td>
			   <td><a href='${ctx}/orderMsg/v2_orderMsgDetail/${o.order.ordeno}'>${o.order.ordeno}</a></td>
			   <td>${o.order.customerOrdeno}</td>
			   <td>${o.order.fromno}</td>
			   <td>${o.expressNo}${o.ebillNo}</td>
			   <td>
			       <c:if test="${o.billType eq 'cbill'}">普通运单</c:if>
				   <c:if test="${o.billType eq 'ebill'}">电子运单</c:if>
			   </td>
			   <td>${o.warehouse.groupName}</td>
			   <td>${o.batchCode}</td>
			   <td>${o.taskCode}</td>
			   <td>
			     <!-- 订单状态 (1.创建批次 2.创建任务 3.已拣货  4.已灯光拣选  9.待包装   5.已包装  6.已发货  7.已签收  8.异常 ) -->
				     <c:if test="${o.status eq '1'}">创建批次</c:if>
				     <c:if test="${o.status eq '2'}">创建任务</c:if>
				     <c:if test="${o.status eq '3'}">已拣货</c:if>
				     <c:if test="${o.status eq '4'}">已灯光拣选</c:if>
				     <c:if test="${o.status eq '9'}">待包装</c:if>
				     <c:if test="${o.status eq '5'}">已包装</c:if>
				     <c:if test="${o.status eq '6'}">已发货</c:if>
				     <c:if test="${o.status eq '7'}">已签收</c:if>
				     <c:if test="${o.status eq '8'}">异常</c:if>
			   </td>
			   <td>
			     <a class="btn btn-default" href='${ctx}/orderMsg/v2_orderMsgDetail/${o.order.ordeno}'>详情</a>
			     <shiro:hasPermission name="/orderMsg/ajaxKuaidiSimulatorTest">
			     <button type="button" class="btn btn-info" style="margin-left: 10px;" onclick="ajaxKuaidiSimulatorTest('${o.id}');" id="simulator_${obj.id }" title="开发测试专用，请勿乱用">虚拟打印</button>
			     </shiro:hasPermission>
			      <shiro:hasRole name="admin">
			     <c:if test="${o.billType eq 'ebill' }">
			       <c:if test="${o.ebillStatus ne 'create' }">
			         <button type="button" class="btn btn-info" style="margin-left: 10px;" onclick="ajaxCreateMailOrdeno('${o.id}');" id="mail_${obj.id }">创建电子面单</button>
			       </c:if>
			     </c:if>
			     
			     <c:if test="${o.sendOutStatus ne 'finish' }">
			       <button type="button" class="btn btn-info" style="margin-left: 10px;" onclick="ajaxSendOutOrdeno('${o.id}');" id="send_${obj.id }">发货</button>
			     </c:if>
			    <button type="button" class="btn btn-info" style="margin-left: 10px;" onclick="ajaxRouteInfo('${o.id}');" id="send_${obj.id }">路由</button>
			   </shiro:hasRole>
			   </td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	</div>
	</div>
  </div>
 </div>
</section>
	
</body>
</html>
